package com.datas.db.hibernatebeans;

import com.datas.utils.hibernatebasebean.SimpleHibernateEntity;
import lombok.Getter;
import lombok.Setter;
import org.json.JSONObject;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.util.Date;

/**
 * Created by jige0727 on 2017/5/15.
 * 登录的token存储
 */
@Getter
@Setter
@Entity
public class UmsUserLoginToken extends SimpleHibernateEntity {
    Integer users_id; //用户账号id
    Date loginTime; //登录时间
    String userType; //账号类型 ums:ums系统的账号 expert:专家账号
//    Date expiresTime; //超时时间

    String access_token;
//    String token_type = "bearer";
//    Integer expires_in = 7200; //超时 暂时不加入超时功能
//    String refresh_token;

    @Column(nullable = false)
    public Integer getUsers_id() {
        return users_id;
    }

    @Transient
    public JSONObject toJson() {
        return new JSONObject()
                .put("access_token", access_token);
    }

    @Transient
    public String toJsonString() {
        return toJson()
                .toString();
    }
}
